package com.yay.euro;

import com.yay.euro.model.LFType;
import com.yay.euro.service.L10N;
import com.yay.euro.service.TicketsService;
import com.yay.euro.tabs.LFList;
import com.yay.euro.tabs.LFMap;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TextView;


/**
 * Get Started!
 * @author yakovlev.yuriy@gmail.com
 * @author Dmitry Makeev
 */
public class Step2 extends TabActivity {
	private TextView description;
	private String s2LDescription; 
	private String s2FDescription; 
	private TabHost _tabHost;
	
	private TextView getDescription() {
		if(description == null) {
			description = (TextView)findViewById(R.id.description);
		    description.setTypeface(L10N.font);
		}
		return description;
	}
	
	private String getS2LDescription() {
		if(s2LDescription == null) {
			s2LDescription = this.getResources().getString(R.string.s2_ldescription);
		}
		return s2LDescription;
	}
	
	private String getS2FDescription() {
		if(s2FDescription == null) {
			s2FDescription = this.getResources().getString(R.string.s2_fdescription);
		}
		return s2FDescription;
	}
	
	private void initTabHost() {
		if(_tabHost == null) {
			_tabHost = (TabHost)findViewById(android.R.id.tabhost);
		    Intent intent = new Intent().setClass(this, LFList.class);
			final TextView dIndicator = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, getTabWidget(), false);
			dIndicator.setText(this.getResources().getString(R.string.lflist));
			TabHost.TabSpec spec = _tabHost.newTabSpec("lflist").setIndicator(dIndicator).setContent(intent);
			_tabHost.addTab(spec);
	
		    intent = new Intent().setClass(this, LFMap.class);
		    final TextView iIndicator = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, getTabWidget(), false);
			iIndicator.setText(this.getResources().getString(R.string.lfmap));
		    spec = _tabHost.newTabSpec("lfmap").setIndicator(iIndicator).setContent(intent);
		    _tabHost.addTab(spec);
	
		    _tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 40;
		    _tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 40;
		        
		    _tabHost.setCurrentTab(0);
		}
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
         L10N.init(this.getResources());
	     setContentView(R.layout.step2);

	     switch(LFType.findById(TicketsService.getCurrentTicket().getType())) {
		     case LOST: getDescription().setText(getS2LDescription());
		     			break;
		     default: 	getDescription().setText(getS2FDescription());
	     }
	     
	     initTabHost();
	}
	
}
